local tieji = fk.CreateSkill{
  name = "lingling__tieji",
}

Fk:loadTranslationTable{
  ["lingling__tieji"] = "铁骑",
  [":lingling__tieji"] = "当你使用【杀】指定目标后，你可以弃置其一张牌，然后若造成伤害，其摸一张牌且所有技能无效（“飞扬”和“跋扈”除外），"..
  "直到你下回合开始。",

  ["@@lingling__tieji"] = "铁骑",
}

tieji:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(tieji.name) and
      data.card.trueName == "slash" and not data.to:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askToSkillInvoke(player, {
      skill_name = tieji.name,
    }) then
      event:setCostData(self, {tos = {data.to}})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local card = room:askToChooseCard(player, {
      target = data.to,
      flag = "he",
      skill_name = tieji.name,
    })
    room:throwCard(card, tieji.name, data.to, player)
    data.extra_data = data.extra_data or {}
    data.extra_data.lingling__tieji = data.extra_data.lingling__tieji or {}
    data.extra_data.lingling__tieji.from = player
    data.extra_data.lingling__tieji.tos = data.extra_data.lingling__tieji.tos or {}
    table.insertIfNeed(data.extra_data.lingling__tieji.tos, data.to)
  end,
})

tieji:addEffect(fk.CardUseFinished, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function (self, event, target, player, data)
    return target == player and data.damageDealt and
      data.extra_data and data.extra_data.lingling__tieji and
      data.extra_data.lingling__tieji.from == player
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room:getAlivePlayers()) do
      if data.damageDealt[p] and not p.dead and table.contains(data.extra_data.lingling__tieji.tos, p) then
        room:addTableMarkIfNeed(p, "@@lingling__tieji", player.id)
        p:drawCards(1, tieji.name)
      end
    end
  end,
})

tieji:addEffect(fk.TurnStart, {
  can_refresh = function (self, event, target, player, data)
    return target == player
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    for _, p in ipairs(room.alive_players) do
      room:removeTableMark(p, "@@lingling__tieji", player.id)
    end
  end,
})

tieji:addEffect("invalidity", {
  invalidity_func = function(self, from, skill)
    return from:getMark("@@lingling__tieji") ~= 0 and skill:isPlayerSkill(from)
  end,
})
return tieji
